# ============================================================================
#	{[iXe[WQiXj
# ============================================================================
include	/pic/pic.mak

# ============================================================================
#	Ώۃt@C
# ============================================================================
OBJS	=	b2hero0 b2hero1 b2hero2 b2hero3 b2hero4 b2hero5 b2hero6\
		b2hero7 b2hero8 b2hero9 crash

CHRS	=	${addsuffix .chr,${OBJS}}\
		b2bg.chr ice.chr
PALS	=	b2hero.pal b2bg.pal ice.pal
SPTS	=	${addsuffix .spt,${OBJS}}\
		ice.spt
ZSBS	=	${addsuffix .zsb,${OBJS}}

BB	=	${BTD}\b2bg.btd
# ============================================================================
#	ŏI^[Qbg
# ============================================================================
all:	${CHRS} ${PALS} ${SPTS} ${BB} ${ZSBS}

spt:	${SPTS}

clean:	clean_spt
	${cmdsplit -rm %,60,${addprefix ${CHR}\,${CHRS}}}
	${cmdsplit -rm %,60,${addprefix ${PAL}\,${PALS}}}
	-rm ${BB}

clean_spt:
	${cmdsplit -rm %,60,${addprefix ${SPT}\,${SPTS}}}
# ============================================================================
#	IȐK
# ============================================================================
#   pbgOFX
# @pbgPFo[g
#@ pbgQFE
#
b2hero.pal:	b2hero0.ccb
	nulcut -c $^ $0
	pakccb -s $0 ${PAL}\${@F}


${BB}:	b2bg.cgb
	cbat -d -X0 -Y0 -x32 -y32 -o$3 $^
	lzss -e $3 ${BB}
	outbin -h -b32,32 ${BB}

# -------------------------------------------------------------------------
#ice.chr:	ice0.csb ice1.csb ice2.csb
#	copy /b ice0.csb+ice1.csb+ice2.csb $0
#	nulcut -s $0 $1
#	prs $1 ${CHR}\${@F}
#
#ice.pal:	ice0.ccb
#	pakccb -u1 -s $^ ${PAL}\${@F}
#
ice.chr ice.pal ice.spt:	ice0.csb ice1.csb ice2.csb ice0.ccb ice.cab
	spcmp -j -o$0 -b0 $^
	prs $0.chr ${CHR}\ice.chr
	pakccb -s $0.pal ${PAL}\ice.pal
	echo  include ${GSYS}\objtbl.h>$0.s
	cabtbl -t -f1 $0.cab >>$0.s
	as -o$0.o $0.s
	lk -b${SPT}\ice.spt /cseg:0,0 $0.o

#
#crash.pal  ice.pal Ɠ
#
#ice.spt:	ice.cab
# -------------------------------------------------------------------------
define	tblgen
echo  include ${GSYS}\objtbl.h>$0.s
echo BANK3=0>>$0.s
cabtbl -t -f1 $^ >>$0.s
as -o$0.o $0.s
lk -b${SPT}\${@F} /cseg:0,0 $0.o
endef

b2hero0.spt:	b2hero0.cab
	${expand ${tblgen}}
b2hero1.spt:	b2hero1.cab
	${expand ${tblgen}}
b2hero2.spt:	b2hero2.cab
	${expand ${tblgen}}
b2hero3.spt:	b2hero3.cab
	${expand ${tblgen}}
b2hero4.spt:	b2hero4.cab
	${expand ${tblgen}}
b2hero5.spt:	b2hero5.cab
	${expand ${tblgen}}
b2hero6.spt:	b2hero6.cab
	${expand ${tblgen}}
b2hero7.spt:	b2hero7.cab
	${expand ${tblgen}}
b2hero8.spt:	b2hero8.cab
	${expand ${tblgen}}
b2hero9.spt:	b2hero9.cab
	${expand ${tblgen}}
